package ca.camosun.proximity.tests;

import static org.junit.Assert.*;

import java.util.Iterator;

import org.junit.Test;

import ca.camosun.proximity.Person;
import ca.camosun.proximity.SavedPerson;

public class DeviceTest {
	
	Person one = new Person ("aaa","gggh");
	Person two = new Person ("Jack","Danels");
	Person three = new Person ("Trog","Dor");
	
	SavedPerson phone = new SavedPerson("Phone","macs");
	SavedPerson cell = new SavedPerson("Cell","small");
	SavedPerson lappy = new SavedPerson("Strong","Bad");
	SavedPerson smart = new SavedPerson("An","Droid");

	@Test
	public void testGetMyDevices() {
		one.addMyDevice(phone);
		two.addMyDevice(smart);
		two.addMyDevice(lappy);
		assertTrue (one.getMyDevices().get(0) == phone);
	}

	@Test
	public void testDeviceCount() {
		one.addMyDevice(phone);
		
		assertTrue(one.deviceCount() == 1);
		
		three.addMyDevice(cell);
		three.addMyDevice(lappy);
		three.addMyDevice(phone);
		
		assertTrue(three.deviceCount() == 3);
		
		three.removeDevice(cell);
		three.removeDevice(lappy);
		one.removeDevice(phone);
		
		assertTrue(three.deviceCount() == 1);
		assertTrue(one.deviceCount() == 0);
	}
	
	@Test
	public void testIteratorByDeviceName() {
		one.addMyDevice(phone);
		one.addMyDevice(smart);
		one.addMyDevice(cell);
		one.addMyDevice(lappy);
		
		Iterator<SavedPerson> iter = one.iteratorByName();

		assertTrue(iter.next() == smart);
		assertTrue(iter.next() == cell);
		assertTrue(iter.next() == phone);
		assertTrue(iter.next() == lappy);
		assertTrue(iter.hasNext() == false);
	}

}
